#ifndef __RPC_TRANSMISSION_CLIENT_H__
#define __RPC_TRANSMISSION_CLIENT_H__

#include "ret.h"
#include "message.h"

#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <pthread.h>

#define IP_ADDRESS_LEN (16)

#define TCP_SEND_BUFFER_SIZE (1024)

extern char g_transmission_running_flag;

typedef struct _tcp_config_t{
    char ip[IP_ADDRESS_LEN];
    int port;
    int timeout;
    int queue_size;
}tcp_client_config_t;

typedef struct _tcp_client_t
{
    tcp_client_config_t* config;
    int fd;
    message_queue_t* queue_wait_for_send;
    pthread_mutex_t mutex;
    pthread_cond_t cond;
    pthread_t thread;
    char send_buffer[TCP_SEND_BUFFER_SIZE];
}tcp_client_t;

tcp_client_t* tcp_client_create(tcp_client_config_t* config);
void tcp_client_destroy(tcp_client_t** client);


#endif // __RPC_TRANSMISSION_CLIENT_H__